

package cn.shengchao.examstar.product.domain.valobj;

import lombok.Data;

import java.math.BigDecimal;

@Data
public class Price {
    private BigDecimal price;

    private Price(BigDecimal price) {
        this.price = price;
    }

    public static Price of(BigDecimal price) {
        if (price == null) {
            return new Price(BigDecimal.ZERO);
        }
        if (price.doubleValue() < 0)
            throw new IllegalArgumentException("价格不能小于0");
        return new Price(price);
    }
}
